<template>
	<view class="page">
		<view class="u-flex u-flex-col success">
			<image class="success-icon" src="../../static/images/huabanfuben.png" mode="widthFix"></image>
			<text class="success-title">{{type==='add'?'分配完成':'修改完成'}}</text>
		</view>
		<u-card padding="0" :border="false" margin="0" border-radius="0" :foot-border-top="false"
			:head-border-bottom="false">
			<view class="card-body" slot="body">
				<view class="u-body-item">
					<view class="item">
						<view class="title">运单号:</view>
						<view class="info">{{demandOrder.transportNo||''}}</view>
					</view>
				</view>
				<view class="u-body-item">
					<view class="item">
						<view class="title">司机:</view>
						<view class="info">{{demandOrder.driverName||''}}</view>
					</view>
				</view>
				<view class="u-body-item">
					<view class="item">
						<view class="title">主车号:</view>
						<view class="info">{{demandOrder.carNo||''}}</view>
					</view>
				</view>
				<view class="u-body-item">
					<view class="item">
						<view class="title">挂车号:</view>
						<view class="info">{{demandOrder.bindCarNo||''}}</view>
					</view>
				</view>
			</view>
		</u-card>
		<u-card padding="0" :border="false" margin="0" border-radius="0" :foot-border-top="false"
			:head-border-bottom="false">
			<view class="card-body" slot="body">
				<view class="table">
					<view class="tr">
						<view class="th">行项目号</view>
						<view class="th">物料</view>
						<view class="th">物料描述</view>
						<view class="th">数量</view>
						<view class="th">交货数量单位</view>
					</view>
					<view class="tr" v-for="(item,index) in demandOrderItemList" :key="index">
						<view class="td">{{item.itemNo||''}}</view>
						<view class="td">{{item.matCode||''}}</view>
						<view class="td">{{item.matDesc||''}}</view>
						<view class="td">{{item.num||''}}</view>
						<view class="td">{{item.unit||''}}</view>
					</view>
				</view>
			</view>
		</u-card>
		<u-button :custom-style="{width:'572rpx'}" shape="circle" type="primary" @click="submit">确认</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				demandOrder: {}, //订单信息
				demandOrderItemList: [], //物料信息
				type: 'add'
			}
		},
		onLoad(option) {
			if (option) {
				if (option.type === 'edit') {
					this.type = option.type
					uni.setNavigationBarTitle({
						title: "修改成功"
					})
				}
				uni.showLoading({
					title: '加载中'
				})
				this.$u.api.carrier.getWaybillDetail({
					id: option.id,
				}).then(data => {
					uni.hideLoading()
					if (data.code === 200 && data.success) {
						this.demandOrder = data.data.transportOrder
						this.demandOrderItemList = data.data.transportOrderItems
					}
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		methods: {
			submit() {
				uni.switchTab({
					url: "./task"
				})
			}
		}
	}
</script>

<style lang="scss">
	.page {
		min-height: 100vh;
		width: 750rpx;
		background-color: #fff;

		.success {
			width: 100%;
			background-color: #fff;
			padding: 60rpx 20rpx 30rpx 20rpx;
			justify-content: center;

			.success-icon {
				width: 188rpx;
			}

			.success-title {
				margin-top: 40rpx;
				font-size: 40rpx;
				color: $uni-color-primary;
			}

			.success-text {
				margin-top: 20rpx;
				font-size: 32rpx;
			}
		}

		.card-head {
			color: $uni-color-primary;
			font-size: 38rpx;
			font-weight: 600;
			padding: 30rpx 0;
			width: 690rpx;
			margin: 0 auto;
			border-bottom: 4rpx solid $uni-color-primary;
		}

		.card-body {
			width: 750rpx;
			padding: 60rpx 30rpx;
			box-sizing: border-box;

			.table {
				width: 100%;
				border: 2rpx solid #e4e7ed;
				display: table;

				.tr {
					width: 100%;
					display: table-row;

					:last-child {
						border-right-width: 0 !important;
					}

					.th {
						width: 20%;
						display: table-cell;
						vertical-align: middle;
						text-align: center;
						font-size: 28rpx;
						color: #303133;
						font-weight: bold;
						background-color: #f5f6f8;
						text-align: center;
						padding: 10rpx 6rpx;
						border-bottom: solid 2rpx #e4e7ed;
						border-right: solid 2rpx #e4e7ed;
						word-break: break-all;
					}

					.td {
						width: 20%;
						display: table-cell;
						vertical-align: middle;
						text-align: center;
						font-size: 26rpx;
						color: #606266;
						text-align: center;
						padding: 10rpx 6rpx;
						border-right: solid 2rpx #e4e7ed;
						word-break: break-all;
					}
				}
			}
		}

		.u-body-item {
			font-size: 28rpx;
			color: #999999;
			width: 100%;
			margin-bottom: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 750rpx;
			box-sizing: border-box;

			.item {
				display: flex;
				justify-content: flex-start;
				align-items: flex-start;

				.title {
					width: 160rpx;
				}

				.info {
					width: 530rpx;
					color: #333333;
					word-break: break-all;
				}
			}

		}
	}
</style>
